<template>
	<el-drawer title="云台控制" v-model="visible" :size="1000" destroy-on-close @closed="$emit('closed')">
		<el-row>
			<el-col :lg="18">
				<scLive :src="info.liveUrl" :isLive="true" :autoplay="true" ref="video" id="live"></scLive>
			</el-col>
			<el-col :lg="6">
				<Rocker @rockChange="setPtzCmdChange"></Rocker>
				<div class="u-flex u-row-center u-m-t-30">
					<el-button type="primary" icon="el-icon-ZoomIn" @click="setPtzCmdChange('IN')">放大</el-button>
					<el-button type="success" icon="el-icon-ZoomOut" @click="setPtzCmdChange('OUT')">缩小</el-button>
				</div>
			</el-col>
		</el-row>
	</el-drawer>
</template>

<script>
	import scLive from '@/components/scVideo/live'
	import Rocker from './Rocker'
	export default {
		emits: ['success', 'closed'],
		components: {
			scLive,
			Rocker
		},
		data() {
			return {
				visible: false,
				info: {
					liveUrl:''
				},
				spin: {
					channel: "",
					direction: "",
					id: "",
					speed: ""
				}
			}
		},

		methods: {
			async setPtzCmdChange(val) {
				console.log(val)
				if(val){
					this.spin.direction = val
				}
				let data = {
					channel: this.info.channel,
					direction: this.spin.direction,
					id: this.info.device,
					mode: "POINT",
					speed: 10
				}
				//this.controlPTz.ptzCmd = val
				const res = await this.$API.api.cam.spin.post(data)
				console.log(res)

			},
			open() {
				this.visible = true
			},
			//表单注入数据
			setData(data) {
				this.visible = true
				console.log(98,data)
				//可以和上面一样单个注入，也可以像下面一样直接合并进去
				Object.assign(this.info, data)
			}
		}
	}
</script>

<style>
</style>
